package com.kcloud.commons.authorization.mp.handler;

import com.baomidou.mybatisplus.extension.parsers.ITableNameHandler;
import com.kcloud.commons.authorization.AuthorizationConfig;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 权限对象动态表名设置，根据业务域编码不同，表名不同
 * @author songhuiqing
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class AuthorizationTableNameHandler implements ITableNameHandler {

    private AuthorizationConfig config;

    @Override
    public String dynamicTableName(MetaObject metaObject, String sql, String tableName) {
            return config.getTableName(tableName);
    }

}
